package com.liyongzhen.filter;
import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import java.io.IOException;
//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {
    @Override//初始化方法，只调用一次
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("Fliter—init方法执行中...");
    }

    @Override//拦截到请求都会调用，会调用多次
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

        System.out.println("Fliter—init拦截到请求_前面");
        chain.doFilter(request,response);
        System.out.println("Fliter—init拦截到请求_后面");

    }

    @Override//销毁方法，只调用一次
    public void destroy() {
        System.out.println("Fliter—init方法已销毁");
    }
}
